const webpack = require('webpack');
const path = require('path');
const commonConfig = require('./webpack.common');

const devConfig = Object.assign({}, commonConfig);

devConfig.mode = 'development';

devConfig.module.rules.unshift({
    resource: path.resolve(__dirname, 'src/api/index.tsx'),
    use: [
        {
            loader: 'api-loader',
            options: {
                url: 'http://localhost:9000/api'
            }
        }
    ]
});

devConfig.plugins.unshift(new webpack.HotModuleReplacementPlugin({
    // Options...
})
);

devConfig.devtool = 'inline-source-map';

devConfig.devServer = {
    host: '0.0.0.0',
    hot: true,
    inline: true,
    port: 9000,
    proxy: {
        '/api/**/*': {
            target: 'http://bundle.hanxiaoxin.cn:1234',
            secure: false
        }
    },
    serveIndex: true,
    compress: false,
    publicPath: '/'
};

// console.log(devConfig)

module.exports = devConfig;